Comparing Arrays and LinkedList, we know it is easy for Array to access element(takes O(1)), but hard to insert or delete(takes O(n)), LinkedList is opposite, access element takes O(n), but deletion and insertion is easy(takes O(1)).

What about comparing elements and find a sepecfic elemnt in a sorted array?

Well, we can do linear search (O(n)). Loop through the elements in array and find out the value that is exact same as target value.

We can also use binary search: repeatedly dividing the search interval in harf to narrow down the search. Binary search only takes O(logn) time complexity.

Continue reading

Recently I found when I use a boolean value in multiple threads, it is not thread-safe enough. For example, in one thread you are writing values for a boolean value, in another thread you are checking the boolean in order to process the thread. How does the program know the value when you check? This suitation also happens in other values not limited to boolean.

We should aviod checking and writing a value in multiple thread in the same time. Here is a simple solution I found: use java.util.concurrent.atomic package. Atomic Collections support lock-free thread-safe programming on single variables.

Continue reading

Open Android Studio badly will possiably cause the following problem:

1
2
3
4
5
6
7
8
Problems found loading plugins:
Plugin "Google Analytics Uploader" was not loaded: required plugin "Android Support" is disabled.
Plugin "SDK Updater" was not loaded: required plugin "Android Support" is disabled.
Plugin "Android NDK Support" was not loaded: required plugin "Android Support" is disabled.
Plugin "Google App Indexing" was not loaded: required plugin "Android Support" is disabled.
Plugin "Google Cloud Tools For Android Studio" was not loaded: required plugin "Android Support" is disabled.
Plugin "Google Cloud Testing" was not loaded: required plugin "Android Support" is disabled.
Plugin "Google Services" was not loaded: required plugin "Android Support" is disabled.
Continue reading

Recently when I enabled Proguard in my program like the following:

1
2
3
4
5
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}

I faced the problem that it tooks like for ever for the process of transformClassesAndResourcesWithProguardForRelease. This problem happens when you have multiple libraries need to be Proguard/Dexguard. Add the line multiDexEnabled true in to your gradle defaultConfig will fix this problem.

Continue reading

Unity 3D Camera

in Unity

I am just starting building up an interesting isometric game. As an Unity3D beginner, I want to collbrate some important components information while I am learning. This blog listed most frequent used elements in Unity3D camera.

Objection:

  • perspective: Camera will render objects with perspective intact. It will look into both visible and invisible objects in 3D.

  • orthographic: Camera will render objects uniformly, with no sense of perspective. It will look into only visible objects. The camera itself is like a plane. If you want to build 2.5D game, or isometric game, you can set camera orthographic.

Continue reading

When you build up an Android library, but not sure if it works properly. When a company has multiple modules and want to allow their employees access and use module easily. Aritifactory is one tool that is useful for speeding up development cycles. You can publish your modules or libraries into Artifactory repositories, and only let people in localhost to use them.

How to install and setup Artifactory?

I am using Linux environment to build up Artifactory. Therefore, I will only talk how to install it in Linux system. If you don’t have Linux system, you can use virtual machine (Virtual Box) or host a Linux system in clouding system (AWS).

Continue reading

After I built up release version of APKs/AARs files and push SDK to Artifactory for exposing Android libraries for developing and testing (I will write an article explaining what is Artifactory), I find out it is still hard to testing. I don’t know what is wrong with my SDKs after I imported to a new App since there is no log for realease version and I cannot use debug mode.

I finally find out one solution. I still feel like it is not the best. However, right now, I have no better solution. If you can solve this problem, please leave your comment and method here, it will help me out a lot.

Continue reading

How to apply Proguard/Dexguard

Proguard/Dexguard shrink and obsfucate resources and codes by scanning and looping up the dependencies. It will do everything it thinks necessary. To apply proguard, simple change minifyEnabled in the module/app you want to apply to be true. Android will apply for Proguard automatically.

1
2
3
4
5
buildTypes {
release {
minifyEnabled true
}
}
Continue reading

Remember in article synch/Asynch Callback in Java I wrote, multithreading in Java is important and can improve performance. We can use callbacks to notify some threads finish executing. What if we don’t need to pass arguments, but we still want to implements multithreads falixable? Another simple way to let a thread wait and wake up is to use Object.wait() and Object.notify().

Keep in mind that:

  • Object.wait() means suspend a thread.
  • Object.notify() means wake a thread up.
Continue reading
Author's picture

Amy Zhu

To learn without thinking is blindness, to think without learning is idleness.


Mapsted Software Engineer


Toronto, ON